<?
ob_start();
session_start();
define( 'SAKE_ROOT', dirname(__FILE__) );

require_once SAKE_ROOT.'/config/config.php';
require_once SAKE_ROOT.'/vendor/sake/sake.php';
require_once SAKE_ROOT.'/app/controllers/application.php';
require_once SAKE_ROOT.'/app/helpers/application.php';

try
{   
    list( $controller, $request, $response, $output ) = biru_controller\dispatcher::dispatch( new biru_controller\cgi() );
    $buffer = $controller->process( $request, $response )->out( $output );
    extract( $controller->properties() );
    echo $buffer;
}
catch( biru_controller\sake_exception $e )
{
    echo $e->unwind();
}
echo ob_get_clean();
?>
